/**
 * @author Mario, Tran
 */
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.io.InputStream;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;

public class panel1 extends JPanel{
	blankButton login;
	blankButton create;
	JTextField loginUserName;
	JTextField ip;
	JLabel ip_label;
	JPasswordField loginUserPw;
	ImageIcon bg,peg;
	Image background,pegasus;
	
	//defaults to student on radio buttons
	//delete this before turn in
	JRadioButton teacher = new JRadioButton("Teacher", false);
	JRadioButton student = new JRadioButton("Student", true);
	//delete this also
	ButtonGroup radiobut = new ButtonGroup();
	
	public panel1(){
	//uses gridbaglayout for easy setup and placement
	//of buttons and textfields
		
	//adds background image to the panel
	bg = new ImageIcon("LoginScreen.png");
	peg = new ImageIcon("pegasus.png");
	pegasus = peg.getImage();
	background = bg.getImage();
	
	//setting my font of choice for easy reading
	Font font = new Font("Ubuntu Mono", Font.BOLD, 16);
	
	//BorderLayout border = new BorderLayout(3,4);//hgap vgap
	this.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	
	ip = new JTextField();
	ip.setPreferredSize(new Dimension(200, 30));
	ip_label = new JLabel("IP: ");
	ip_label.setFont(font);
	
	c.insets = new Insets(200,0,5,5);
	c.gridy =0;
	login = new blankButton("Start");
	create = new blankButton("Create Account");
	login.setFont(font);
	create.setFont(font);
	
	loginUserName = new JTextField();
	JLabel loginLabel = new JLabel("User Name:"); 
	//loginLabel.setFont(new Font("Ubuntu-M.ttf", Font.PLAIN, 16));
	
	loginLabel.setFont(font);
	
	loginUserName.setPreferredSize(new Dimension(200, 30));
	this.add(loginLabel,c);
	this.add(loginUserName,c);
	c.insets = new Insets(0,0,5,5);
	loginUserPw = new JPasswordField();
	loginUserPw.setPreferredSize(new Dimension(200, 30));
	JLabel passLabel = new JLabel("Password:");
	passLabel.setFont(font);
	
	c.gridy=1;
	this.add(passLabel,c);
	this.add(loginUserPw,c);
	
	//adds the radio buttons into one group
	radiobut.add(student);
	radiobut.add(teacher);
	student.setFont(font);
	teacher.setFont(font);
	//adds the student / teacher radio buttons.
	c.gridy = 3;
	
	this.add(student, c);
	this.add(teacher, c);
	
	c.gridy = 4;
	c.gridwidth = 1;
	c.insets = new Insets(10,2,2,2);
	
	this.add(login,c);
	c.insets = new Insets(10,2,2,2);
	c.gridx = 1;
	c.gridy = 4;
	this.add(create, c);
	
	
	c.gridx = 0;
	c.gridy = 2;
	c.insets = new Insets(0,0,5,5);
	this.add(ip_label, c);
	
	c.gridx = 1;
	this.add(ip, c);
	
	
	
	/*delete this block of code before submission, unneeded atm
	Container c1 = new Container();
	c1.setLayout(new GridLayout(3,1,5,5));//rows cols Hsep Vsep
	loginUserName = new JTextField(12);
	loginUserName.setSize(new Dimension(30,10));
	c1.add(loginUserName);
	
	c1.add(loginUserPw = new JPasswordField(12));
	
	
	
	
	Container c2 = new Container();
	c2.setLayout(new FlowLayout());
	c2.add(login = new JButton("Login"));
	JButton quit;
	c2.add(quit = new JButton("Exit"));
	
	c1.add(c2);
	add(c1,BorderLayout.CENTER);
	JPanel p;
	*/
	//add(p = new JPanel(),BorderLayout.NORTH);
	
	//add(login = new JButton("login"));
	}
	
	public void paintComponent(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		GradientPaint p;
		p = new GradientPaint(0, 50, Color.WHITE, 0, getHeight()*2,new Color(123,53,153));//variation of purple RGB

		Paint oldPaint = g2.getPaint();
		g2.setPaint(p);
		g2.fillRect(0, 0, 800, 600);
		g2.setPaint(oldPaint);
		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		g.drawImage(background, 0, 0, null);
		g.drawImage(pegasus, 375,500,null);
	  }
}
